package com.huluobo.higt4demo1911.ui.video;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.huluobo.higt4demo1911.R;
import com.huluobo.higt4demo1911.adapter.MyItemDecoration;
import com.huluobo.higt4demo1911.adapter.VideoItemAdapter;
import com.huluobo.higt4demo1911.bean.VideoBean;
import com.huluobo.higt4demo1911.contract.VideoContract;
import com.huluobo.higt4demo1911.core.mvp.BaseFragment;
import com.huluobo.higt4demo1911.presenter.VideoPresenter;

import java.util.List;

/**
 * Created by lc on 2022/4/27.
 */
public class VideoItemFragment extends BaseFragment<VideoPresenter> implements VideoContract.View {
    private RecyclerView recyclerView;
    private VideoItemAdapter mAdapter;

    @Override
    public void initAdapter(List<VideoBean> videoBeans) {
        if (mAdapter == null) {
            mAdapter = new VideoItemAdapter(videoBeans);
            recyclerView.setAdapter(mAdapter);
        }
    }

    @Override
    public int bindLayout() {
        return R.layout.fragment_video_cart_list;
    }

    @Override
    public void initView() {
        recyclerView = findViewById(R.id.fragment_video_rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        recyclerView.addItemDecoration(new MyItemDecoration());
    }

    @Override
    public void initData() {
        mPresenter = new VideoPresenter(this);
        mPresenter.list();
    }
}
